#! /bin/sh  
#
#	Installation shell script for Catalyst CDware
#
#       Usage: install -m<mountpoint> -p<productpath>
#
#	Created: 	June 12, 1991
#       Last Revised:   May 28, 1996
#                 
#	Use this installation script to install your product from Catalyst CDware
#
#
#	For technical support, please call.
#		+1 415 336.3742 (CDware SPARC) or +1 415 336.3941 (CDware x86)
#
#	get command line parameters
#

# function for error exiting

end_it () {
echo " "
  echo "Hit return to end ... "
  read answer
 
exit 0
}


#	set PRODUCT_SIZE to the size of your product in kbytes 	

PRODUCT_SIZE=24000

#
#	get complete paths
#
#
#	get location of installation directory 
##
echo
#echo "Please enter the absolute path name of the directory structure in which"
#echo "you would like to install the NetWorker evaluation program."
#echo
#echo "Installation directory: "
#read INSTALL_DIR

INSTALL_DIR=/tmp/networker

#
#	verify the installation directory exists and is a directory
#
if [ ! -d "$INSTALL_DIR" ]
then
	echo "Creating $INSTALL_DIR ..."
	mkdir $INSTALL_DIR
	if [ ! -d "$INSTALL_DIR" ]
	then
		echo
		echo
		echo "Could not create the installation directory."
		echo
		echo "Exiting the installation script."
                end_it
	fi
fi

#
#	verify write permission for the installation directory
#
if [ ! -w "$INSTALL_DIR" ]
then
	echo
	echo
	echo "You do not have write permission for the installation directory: "
	echo $INSTALL_DIR
	echo
		echo
	echo "Exiting the installation script."
        end_it
fi

#
#	verify free disk space
#
echo	
echo	"Verifying free disk space..."
FREE_SPACE=0
df=/tmp/FREE.$$
#
# WARNING:
# --------
# For Solaris 2.4, the df line below will need to be updated because
# the standard output of the df command has changed in Solaris 2.4
#
/usr/bin/df -k $INSTALL_DIR | sed /kbytes/d | sed -e '3,$d' | sed -e '1,$s/  */ /g' > $df

case `/usr/bin/wc -l $df | sed -e 's/^ *//' | cut -f1 -d" " ` in
	1) FREE_SPACE=`cat $df | cut -f4 -d" "` ;; 
	2) FREE_SPACE=`cat $df | sed 1d | sed 's/^ *//' | cut -f3 -d" "` ;; 
esac

if [ -n $FREE_SPACE ]
then
	if [ $FREE_SPACE -lt $PRODUCT_SIZE ]
	then
		echo
		echo
		echo "The product installation requires $PRODUCT_SIZE kbytes of"
		echo "free disk space. There is only $FREE_SPACE kbytes of free" 
		echo "disk space in the selected filesystem.  Please free up some"
		echo "disk space and try this installation again."
		echo
		echo "Exiting the installation script."
	        end_it 	
	fi
fi
/bin/rm $df 2>/dev/null

#
#	copy binaries to installation directory
#
echo 
echo "Copying files to "$INSTALL_DIR"..."
echo
#
# uncomment the following line to do the actual copy
#

cd $INSTALL_DIR

cp $COMPANY_DIR/forms/nw_sol.tar.Z $INSTALL_DIR

cd $INSTALL_DIR
uncompress nw_sol.tar.Z
echo " "
echo " Uncompressing nw_sol.tar.Z ..."
echo " "
echo " "
echo " Extracting nw_sol.tar ..."

tar xvf nw_sol.tar
cd $INSTALL_DIR/SOLARIS
/usr/sbin/pkgadd -d ./SOLARIS.PKG
echo " "
echo " "
echo " Installation was a success."
sleep 2
more $COMPANY_DIR/_install/readme.txt

end_it
